﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace tactics.Abilities
{
    public class DamageAbility : BaseAbilityComponent
    {
        int damage;
        int hits;
        DamageType type;

        #region Properties

        public int Damage
        {
            get { return damage; }
            set { damage = value; }
        }

        public int Hits
        {
            get { return hits; }
            set { hits = value; }
        }

        public DamageType Type
        {
            get { return type; }
            set { type = value; }
        }

        #endregion

        public DamageAbility()
        {
        }

        public DamageAbility(int damageIn, int hitsIn, DamageType typeIn)
        {
            damage = damageIn;
            hits = hitsIn;
            type = typeIn;
        }

        public override void SetProperty(string property, string value)
        {
            switch (property)
            {
                case "damage":
                    damage = int.Parse(value);
                    break;

                case "hits":
                    hits = int.Parse(value);
                    break;

                case "type":
                    type = (DamageType)Enum.Parse(typeof(DamageType), value);
                    break;
            }
        }

        public override void UseAbility(Unit unit)
        {
            base.UseAbility(unit);
           
            for (int i = 0; i < hits; ++i )
            {
                unit.AddDamage(damage, type);
            }
        }
    }
}
